package com.zork.cmdb.webapi.mapper.smartoms;

import com.zork.cmdb.webapi.domain.dbo.AutoFindResultDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author chenjh
 * @date 2018/6/25
 * @description
 */
@Mapper
public interface AutoFindResultMapper {
    @Select("SELECT id,\n" +
            "extid,\n" +
            "result,\n" +
            "begin_time as beginTime,\n" +
            "end_time as endTime,\n" +
            "ci_code as ciCode\n" +
            "FROM cmdb_timeTask_result \n" +
            "WHERE DATE_SUB(CURDATE(), INTERVAL 3 DAY) <= begin_time \n" +
            "AND ci_code IS NOT NULL \n" +
            "ORDER BY begin_time DESC")
    List<AutoFindResultDO> listAutoFindResult();

    @Select("SELECT id,\n" +
            "extid,\n" +
            "result,\n" +
            "begin_time as beginTime,\n" +
            "end_time as endTime,\n" +
            "ci_code as ciCode\n" +
            "FROM cmdb_timeTask_result \n" +
            "WHERE DATE_SUB(CURDATE(), INTERVAL 3 DAY) <= begin_time \n" +
            "AND ci_code = #{ciCode} \n" +
            "ORDER BY begin_time DESC")
    List<AutoFindResultDO> getAutoFindResultByCiCode(@Param("ciCode") String ciCode);
}
